# 快速排序


def quicksort(arr):
    if len(arr) < 2:
        return arr
    else:
        flag = arr[0]
        less = [i for i in arr[1:] if i <= flag]
        greater = [i for i in arr[1:] if i > flag]
        return quicksort(less)+[flag]+quicksort(greater)


print(quicksort([1, 3, 2, 5, 4, 9, 8, 6, 7]))
